package com.ny.utils;

import com.ny.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class TestEmailSender {
    
    @Autowired
    private UserService userService;
    
    @Autowired
    private EmailUntil emailUntil;
    
    /**
     * 测试发送验证码到指定邮箱
     * @param email 接收验证码的邮箱
     */
    public void testSendVerificationCode(String email) {
        try {
            // 生成验证码
            String code = EmailUntil.generateVerificationCode();
            System.out.println("生成的验证码: " + code);
            
            // 发送邮件
            emailUntil.sendVerificationCode(email, code);
            System.out.println("已尝试向 " + email + " 发送验证码");
        } catch (Exception e) {
            System.err.println("发送验证码失败: " + e.getMessage());
            e.printStackTrace();
        }
    }
}